﻿using Plugins.Base.Historical;
using StockModel;
using TrixPlugin.Common;

namespace TrixPlugin.Historical
{
	internal class HistoricalEngine : Plugins.Base.Historical.HistoricalEngineBase
	{
		#region Attributes

		private readonly DecisionEngineData _decisionEngineData;

		private DecisionEngine _decisionEngine;

		#endregion

		#region Properties

		public new HistoricalSettings Settings
		{
			get
			{
				return (HistoricalSettings)base.Settings;
			}
			set
			{
				base.Settings = value;
			}
		}

		#endregion

		#region Public Methods

		public HistoricalEngine(QuotationDataSource quotationDataSource, RawStockDataSource rawStockDataSource) : base(quotationDataSource, rawStockDataSource)
		{
			_decisionEngineData = new DecisionEngineData(); // Reuse the engine data on each execution
		}

        protected override HistoricalDayProcessorBase CreateDayProcessor()
        {
            HistoricalDayProcessorBase processor = new HistoricalDayProcessorBase(base.QuotationDataSource, base.RawStockDataSource, this.Settings.HourOptions, this.Settings.StockParameters, this.Settings.StrategyControlData.Inverted);

            _decisionEngine = new DecisionEngine(_decisionEngineData, processor.DataFeeder.Data, this.Settings.StrategyControlData, this.Settings.HourOptions, processor.OperationManager);

            return processor;
        }

		#endregion
	}
}
